#ifndef MISC_H
#define MISC_H

#define WORKING 0

/** Error variable. */
extern int errno;

/** Structures. */
struct info_thread_arg
{
	struct info_table *shm;
	int sem_id;
};

struct logger_thread_arg
{
	int 	client_sock;
	struct 	sockaddr_in cliaddr;
	struct 	info_table *shm;
	int		sem_id;
	pid_t 	slave_pid;
	FILE	*primes_file;
};

struct info_table
{
	char 	ip[MAX_SLAVES][16];
	int  	port[MAX_SLAVES];
	int  	worker_port[MAX_SLAVES];
	int  	pid[MAX_SLAVES];
	char 	idle[MAX_SLAVES];
	char 	alive[MAX_SLAVES];
	int  	number[MAX_SLAVES];
	int  	count;
	ULL  	n;
};

union semun
{
	int 				val;
	struct semid_ds		*buf;
	unsigned short int	*array;
	struct seminfo		*__buf;
};

struct prime_str
{
   int number;
   unsigned long long value;
   /** 0 - not sent, 1 - sent. */
   char sent;
   /** 0 - not received, 1 - received and not a divisor, 2 - received and a divisor. */
   char received;
};

/** Address b1.b2.b3.b4 has to be packed as 0xb1b2b3b4. */
const unsigned int MY_IP = 0x7f000001;

#endif // !MISC_H
